JavaScript

A5.u.jsoncompress Method

Syntax

A5.u.json.compress(object,map)

Arguments

objectobjectarray

The object or array to compress.

mapobject

The object that will be dynamically filled in with the property name map.

Returns

compressedObjectobject

The compressed version of the passed in object.

Description

Compress an object for storage purposes.

Discussion

This method will take an arbitrary object and convert all property names to a short name (such as "a"). The passed in map object will be populated with the long names to match the short names generated, to be used by A5.u.json.expand to return the original uncompressed object. This is useful for compressing large, repetitive data.

Example

var map = {};
var obj = [{name: 'Bob', age: 54},{name: 'Fred', age: 32}];
var cObj = A5.u.json.compress(obj,map);
// cObj = [{a: 'Bob', b: 54},{a: 'Fred', b: 32}];
// map = {a: 'name', b: 'age'};